# this file should be included on top of the configurations that wish to use only
# wondercap's compatible extensions

require "pathname"
additional_path = Pathname.new(__FILE__).realpath.dirname.join("..", "..", "..", "..")
$: << additional_path
load_paths << additional_path

require "wondercap/lib/deployment/core/outer_configuration_mixin"
require "wondercap/lib/deployment/core/inner_configuration_mixin"
require "ostruct"

class << top; self; end.class_eval do
  include Wondercap::Deployment::InnerConfigurationMixin
  
  (Wondercap::Deployment::OuterConfigurationMixin.public_instance_methods + Wondercap::Deployment::OuterConfigurationMixin.private_instance_methods).each do |mname|
    define_method mname do |*args|
    end
  end
  
  def define_extension(*args, &block)
    compat_outer_configuration.define_extension(*args, &block)
  end
  
  def get_substrategy_extension(*args, &block)
    compat_outer_configuration.get_substrategy_extension(*args, &block)
  end

  def compat_outer_configuration
    unless @compat_outer_configuration
      @compat_outer_configuration = Configuration.new
      class << @compat_outer_configuration; self; end.class_eval do
        include Wondercap::Deployment::OuterConfigurationMixin
      end
      
      class << strategy; self; end.class_eval do
        attr :project_name, true
      end
    end
    @compat_outer_configuration
  end
  
  def mc
    OpenStruct.new :initializers => []
  end
  
  def compat_extension
    self.outer_configuration = compat_outer_configuration
    yield
  end
end
